package com.xxxx;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;

public class Hello03FlinkOperatorFilter {

    public static void main(String[] args) throws Exception {
        //获取执行环境
        ExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();
        //获取数据源
        DataSource<Integer> source = environment.fromElements(1, 2, 3, 4, 5, 6, 7, 8);
        //开始进行转换
        source.filter(new FilterFunction<Integer>() {
            @Override
            public boolean filter(Integer i) throws Exception {
                //保留所有的单数
                return i % 2 == 1;
            }
        }).filter((Integer num) -> {
            return num > 3;
        }).print();


    }


}
